package com.subsequent.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.subsequent.mapper.CampusesMapper;
import com.subsequent.pojo.Campuses;
import com.subsequent.service.CampusesService;
import org.springframework.stereotype.Service;
import java.util.Date;

@Service
public class  CampusesServiceImpl extends ServiceImpl<CampusesMapper, Campuses> implements CampusesService {
    // 可扩展自定义方法

    @Override


    public Page<Campuses> pageQuery(int pageNum, int pageSize, String campusName, Integer status, Date startTime, Date endTime) {
        LambdaQueryWrapper<Campuses> wrapper = new LambdaQueryWrapper<>();
        if (campusName != null && !campusName.isEmpty()) {
            wrapper.like(Campuses::getCampusName, campusName);
        }
        if (status != null) {
            wrapper.eq(Campuses::getStatus, status);
        }
        if (startTime != null) {
            wrapper.ge(Campuses::getCreatedAt, startTime);
        }
        if (endTime != null) {
            wrapper.le(Campuses::getCreatedAt, endTime);
        }
        wrapper.orderByDesc(Campuses::getCreatedAt);
        Page<Campuses> page = new Page<>(pageNum, pageSize);
        return this.page(page, wrapper);
    }
} 